package com.learn.springlearn.filter;

import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 *
 */
public class LogFilter extends OncePerRequestFilter {




    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {

//        System.out.println("进入了过滤器获取sessionId："+httpServletRequest.getRequestedSessionId());
        System.out.println("获取到的sessionId:"+httpServletRequest.getSession().getId());

        httpServletRequest.getParameterMap().forEach((key,value)->{
            System.out.println("key:"+key+"  value:"+ Arrays.toString(value));
        });
        filterChain.doFilter(httpServletRequest,httpServletResponse);

    }
}
